package day7.zhujie;

import day7.zhujie.Calculator;

import java.lang.reflect.Method;
import java.util.ArrayList;

/**
 * @author oldliu
 * @since 1.0
 */
public class CalcTest {
    public static void main(String[] args) throws Exception {
        Calculator c = new Calculator();
        //System.out.println(c.add(4,6));
        Class<? extends Calculator> cls = c.getClass();
        Method add = cls.getDeclaredMethod("mul", int.class, int.class);
        if (add.isAnnotationPresent(MyTest.class)) {//存在
            //获得注解的配置对象
            MyTest my = add.getAnnotation(MyTest.class);
            System.out.println(my.before());
            Object re = add.invoke(c, 10, 20);
            System.out.println(re);
            System.out.println(my.after());
        } else {
            Object re = add.invoke(c, 10, 20);
            System.out.println(re);
        }

    }
}
